<#include "/admin/inc/ctx.html">
<link href="${ctx }/webapp/static/lib/treetable/jquery.treetable.css" rel="stylesheet" type="text/css" media="screen" />
<link href="${ctx }/webapp/static/lib/treetable/jquery.treetable.theme.default.css" rel="stylesheet" type="text/css" media="screen"/>
<script src="${ctx }/webapp/static/lib/treetable/jquery.treetable.js" type="text/javascript"> </script>
<script type="text/javascript">
$(function () {
    var option = {
    		theme:'vsStyle',
    		column:2,
    		expandable:true
    };
    $('#modelTable',navTab.getCurrentPanel()).treetable(option);//根据表格id来初始化
    $("#modelTable",navTab.getCurrentPanel()).treetable("expandAll");
});
</script>
<style>
#modelTable th{border-top: 1px solid #B8D0D6;font-weight: bolder;}
#modelTable th,#modelTable td{border-left: solid 1px #E7E7E7;border-right: 1px solid #E7E7E7;border-bottom: 1px solid #E7E7E7;line-height: 22px;background: white;}
</style>

<#macro _module_table records>
	<#list records as child>
		<tr data-tt-id='${child.id}' data-tt-parent-id='${child.pId}' target="id" rel="${child.id}">
			<td><input type="checkbox" name="ids" value="${child.id }" /></td>
			<td>${child.id}</td>
			<td>${child.name}</td>
			<td>${_dict_cn_name("${child.moduleType}")}</td>
			<td>${child.href}</td>
			<td>${(child.authorize)!}</td>
			<td>${(child.icon)! }</td>
			<td>${(child.sort)! }</td>
			<td align="center">
			<@shiro.hasPermission name="admin:module:delete"> 
			<a title="删除" target="ajaxTodo" callback="ajaxTodoDone" href="${ctx }/admin/module/delete?id=${child.id}" class="delButton"><i class="fa fa-remove"></i>&nbsp;删除</a> 
			</@shiro.hasPermission> 
			<@shiro.hasPermission name="admin:module:form"> 
			<a title="编辑" target="dialog" width="740" height="300" href="${ctx}/admin/module/form?id=${child.id }" class="editButton"><i class="fa fa-file-text-o"></i>&nbsp;编辑</a> 
			</@shiro.hasPermission>
			</td>
		</tr>
		<@_module_table records=child.children />
	</#list> 
</#macro>

<form id="pagerForm" method="post" action="${ctx}/admin/module/treePage">
	<input type="hidden" name="pageNum" value="1" />
</form>
<div class="pageContent">
<div class="panelBar" style="margin-top: 1px;">
		<ul class="toolBar">
		    <@shiro.hasPermission name="admin:module:form">
			<li><a class="add" href="${ctx}/admin/module/form" target="dialog" width="740" height="300"><i class="fa fa-plus"></i>添加</a></a></li>
			</@shiro.hasPermission>
			<li class="line">line</li>
		</ul>
	</div>
	<div layoutH="15" style="margin-top: 1px;">
		<table id="modelTable" style="margin-top: 0;">
			<thead>
				<tr>
				    <th width="2%"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
				    <th width="3%">编号</th>
					<th width="15%">模块名称</th>
					<th width="5%">类型</th>
					<th width="20%">URL</th>
					<th width="15%">授权</th>
					<th width="10%">图标</th>
					<th width="3%">排序</th>
					<th width="10%">操作</th>	       
				</tr>
			</thead>
			<tbody>
				<#list pageData as bean> 
				     <#if bean.pId??>
						<#else>
						<tr data-tt-id='${bean.id}' target="id" rel="${bean.id }">
							<td><input type="checkbox" name="ids" value="${bean.id }" /></td>
							<td>${bean.id}</td>
							<td>${bean.name}</td>
							<td>${_dict_cn_name("${bean.moduleType}")}</td>
							<td>${bean.href}</td>
							<td>${(bean.authorize)!}</td>
							<td>${(bean.icon)! }</td>
							<td>${(bean.sort)! }</td>
							<td align="center">
							   <@shiro.hasPermission name="admin:module:delete"> 
							      <a title="删除" target="ajaxTodo" callback="ajaxTodoDone" href="${ctx }/admin/module/delete?id=${bean.id}" class="delButton"><i class="fa fa-remove"></i>&nbsp;删除</a> 
							   </@shiro.hasPermission> 
							   <@shiro.hasPermission name="admin:module:form">
							      <a title="编辑" target="dialog" width="740" height="300" href="${ctx}/admin/module/form?id=${bean.id }" class="editButton"><i class="fa fa-file-text-o"></i>&nbsp;编辑</a> 
							    </@shiro.hasPermission>
							</td>
						</tr>
						<@_module_table records=bean.children />
					 </#if>
				</#list>
			</tbody>
		</table>
	</div>
</div>
